<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<style>
			.datepicker-input{height: 34px; border: 1px solid #D3D3D3; background-color: #fff; border-radius: 2px; width: 250px; padding: 0px 4px;}
			#adminOrderEditForm .form-item {margin-bottom: 20px; width: 50%; float: left;}
			#adminOrderEditForm .form-item>label{min-width: 72px; display: inline-block; text-align: right;}
			
			#adminOrderSkuEditForm .form-item{margin-bottom: 20px;}
			#adminOrderSkuEditForm .form-item>label{min-width: 72px; display: inline-block; text-align: right;}
			
			#otherOrderForm .form-item{margin-bottom: 20px;}
			#otherOrderForm .form-item>label{min-width: 72px; display: inline-block; text-align: right;}
			.input-file{position: absolute; left: 0px; top: 0px; display: inline-block; width: 100%; height: 30px; line-height: 30px; opacity: 0;}
		</style>
		<div class="super-theme-example">
			<div class="options-toolbar">
				<form id="adminOrderdatagridQueryParams">
					<input class="easyui-textbox" name="code" data-options="width:120,prompt:'订单编号'">
					<select class="easyui-combobox" name="status" style="width:120px;">
					    <option value="">全部状态</option>
					    <option value="10">备货中</option>
					    <option value="20">配货中</option>
					    <option value="30">运输中</option>
					    <option value="40">签收</option>
					    <option value="-10">取消</option>
					    <option value="-20">拒收</option>
					</select>
					<input class="easyui-textbox" name="deliveryCode" data-options="width:120,prompt:'发货单号'">
					<input class="easyui-textbox" name="remark" data-options="width:120,prompt:'订单备注'">
					<select class="easyui-combobox" name="payment" style="width:120px;">
					    <option value="">全部方式</option>
					    <option value="1">货到付款</option>
					    <option value="2">stripe</option>
					</select>
					<select class="easyui-combobox" name="source" style="width:120px;">
					    <option value="">全部来源</option>
					    <option value="XX">XX</option>
					    <option value="XH">XH</option>
					    <option value="SHOP">SHOP</option>
					    <option value="UPLOAD">UPLOAD</option>
					</select>
					<input class="easyui-textbox" name="productId" data-options="width:120,prompt:'商品ID'">
					<input class="easyui-textbox" name="productSkuBarcode" data-options="width:120,prompt:'商品SKU编码'">
					<input class="easyui-textbox" name="tel" data-options="width:120,prompt:'电话号码'">
					
					
					<input id="adminOrder-datepicker" class="datepicker-input" />
					<a href="javascript:void(0)" class="easyui-linkbutton primary" data-options="iconCls:'fa fa-search'" onclick="admin_order.methods.queryDatagrid();">查询</a>
				</form>
				<div class="top-options">
					<a href="javascript:void(0)" class="easyui-menubutton info" data-options="menu:'#admin_order_tools'">操作</a>
					<div id="admin_order_tools" style="width:120px;">
						<div data-options="iconCls:'fa fa-upload'">
							<span class="input-span">上传订单</span>
							<input class="input-file" type="file" onchange="admin_order.methods.uploadOrders(this);this.value = null;" />
						</div>
						<div class="menu-sep"></div>
						<div data-options="iconCls:'fa fa-cart-plus'" onclick="admin_order.methods.merge()">合并订单</div>
						<div class="menu-sep"></div>
						<div data-options="iconCls:'fa fa-cart-plus'" onclick="$('#otherOrderWin').window('open');">获取订单</div>
						<div class="menu-sep"></div>
						<div data-options="iconCls:'fa fa-download'" onclick="exportExcel(commonConfig.mgUrlPrefix() + '/admin/order/export' , admin_order.methods.initDatagridQueryParams())">导出</div>
						<div class="menu-sep"></div>
						<div data-options="iconCls:'fa fa-trash-o'" onclick="admin_order.orderAction.cancels()">批量取消</div>
						<div class="menu-sep"></div>
						<div data-options="iconCls:'fa fa-trash-o'" onclick="admin_order.orderAction.deletes()">批量删除</div>
					</div>
				</div>
			</div>
			<table id="adminOrder-datagrid"></table>
			<div id="adminOrder-skuDetais-window" class="easyui-window" title="订单商品详情" style="width:1200px;height:550px" data-options="modal:true,closed:true,minimizable:false,maximizable:false,tools:[{iconCls:'fa fa-plus-square',handler:function(){admin_order.methods.splitOrder();}}]">
				<table id="adminOrder-skuDetais-datagrid" style="height: 500px;"></table>
			</div>
			
			<div id="adminOrderEditWin" class="easyui-window" title="编辑订单" style="width:700px;height:350px" data-options="modal:true,closed:true,minimizable:false,maximizable:false">
				<div class="super-theme-example">
					<form id="adminOrderEditForm">
						<input name="code" type="hidden">
						<div class="form-item">
							<label for="" class="label-top">总价：</label>
							<input name="price" class="easyui-textbox" style="width: 250px;" prompt="价格...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">运费：</label>
							<input name="freight" class="easyui-textbox" style="width: 250px;" prompt="运费...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">备注：</label>
							<input name="remark" class="easyui-textbox" style="width: 250px;" prompt="备注...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">优先级：</label>
							<input name="priority" class="easyui-textbox" style="width: 250px;" prompt="优先级...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">收件人：</label>
							<input name="consignee" class="easyui-textbox" style="width: 250px;" prompt="收件人...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">电话：</label>
							<input name="tel" class="easyui-textbox" style="width: 250px;" prompt="电话...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">城市：</label>
							<input name="city" class="easyui-textbox" style="width: 250px;" prompt="城市...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">区域：</label>
							<input name="district" class="easyui-textbox" style="width: 250px;" prompt="区域...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">详细地址：</label>
							<input name="details" class="easyui-textbox" style="width: 250px;" prompt="详细地址...">
						</div>
					</form>
					<div style="text-align: center; box-sizing: border-box;padding: 10px;">
						<a href="#" class="easyui-linkbutton" style="width: 80px;" onclick="$('#adminOrderEditWin').window('close');">取消</a>
						<a href="#" class="easyui-linkbutton primary" style="width: 80px;" onclick="admin_order.orderAction.editOrderSubimt();">保存</a>
					</div>
				</div>
			</div>
			
			<div id="adminOrderSkuEditWin" class="easyui-window" title="编辑订单产品" style="width:380px;height:410px" data-options="modal:true,closed:true,minimizable:false,maximizable:false">
				<div class="super-theme-example">
					<form id="adminOrderSkuEditForm">
						<input name="orderProductId" type="hidden">
						<div class="form-item">
							<label for="" class="label-top">产品价格：</label>
							<input name="productPrice" class="easyui-textbox" style="width: 250px;" prompt="产品价格...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">购买数量：</label>
							<input name="quantity" class="easyui-textbox" style="width: 250px;" prompt="购买数量...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">货号：</label>
							<input name="sourceNumber" class="easyui-textbox" style="width: 250px;" prompt="货号...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">参考采购价：</label>
							<input name="referencePurchasePrice" class="easyui-textbox" style="width: 250px;" prompt="参考采购价...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">采购来源：</label>
							<input name="sourceUrl" class="easyui-textbox" style="width: 250px;" prompt="采购来源...">
						</div>
					</form>
					<div style="text-align: right; box-sizing: border-box;padding: 10px;">
						<a href="#" class="easyui-linkbutton" style="width: 80px;" onclick="$('#adminOrderSkuEditWin').window('close');">取消</a>
						<a href="#" class="easyui-linkbutton primary" style="width: 80px;" onclick="admin_order.orderAction.editOrderSkuSubimt();">保存</a>
					</div>
				</div>
			</div>
			
			<div id="otherOrderWin" class="easyui-window" title="导入订单" style="width:380px" data-options="modal:true,closed:true,minimizable:false,maximizable:false">
				<div class="super-theme-example">
					<form id="otherOrderForm">
						<div class="form-item">
							<label for="" class="label-top">订单编号：</label>
							<input name="orderCode" class="easyui-textbox" style="width: 250px;" prompt="订单编号...">
						</div>
						<div class="form-item">
							<label for="" class="label-top">导入数量：</label>
							<input name="loopCount" class="easyui-textbox" style="width: 250px;" prompt="导入数量...">
						</div>
					</form>
					<div style="text-align: right; box-sizing: border-box;padding: 10px;">
						<a href="#" class="easyui-linkbutton" style="width: 80px;" onclick="$('#otherOrderWin').window('close');">取消</a>
						<a href="#" class="easyui-linkbutton primary" style="width: 80px;" onclick="admin_order.methods.others();">保存</a>
					</div>
				</div>
			</div>
			
		</div>
		<script type="text/javascript" src="dists/super/js/xlsx.full.min.js" ></script>
		<script type="text/javascript">
			var admin_order = {
				datas : {
					orderCode: null,
					orderStatus: null 
				} ,
				methods : {
					initDatagridQueryParams: function(){
						var params = $('#adminOrderdatagridQueryParams').serializeArray();
						var queryParams = {};
						$.each(params , function(index , param){
						     queryParams[param.name] = param.value;
						})
						var time = $('#adminOrder-datepicker').val();
						queryParams.begainTime = timestamp(time.substring(0, 19));
						queryParams.endTime = timestamp(time.substring(22));
						
						queryParams.code = queryParams.code.replace(/[\r\n，]/g,",");
						queryParams.tel = queryParams.tel.replace(/[\r\n，]/g,",");
						queryParams.deliveryCode = queryParams.deliveryCode.replace(/[\r\n，]/g,",");
						queryParams.productId = queryParams.productId.replace(/[\r\n，]/g,",");
						//queryParams.consignee = queryParams.consignee.replace(/[\r\n，]/g,",");
						
						return queryParams;
					},
					initTimeSelect: function(){
						$('#adminOrder-datepicker').daterangepicker($.extend(true, {} , globalDaterangepickerOptions));
					},
					initDatagrid : function(){
						
						$('#adminOrder-datagrid').datagrid({
							height: $(document).height() - 200,
						    url: commonConfig.mgUrlPrefix() + '/admin/order/list',
						    queryParams: {
								begainTime: timestamp($('#adminOrder-datepicker').val().substring(0, 19)),
								endTime: timestamp($('#adminOrder-datepicker').val().substring(22))
							},
						    columns:[[
								{field:'ck',checkbox:true,width:50,align:'center'},
								{field:'code',title:'编码',width:100,align:'center',formatter: function(value,row,index){
									return '<a onclick="admin_order.methods.showSKU(\''+value+'\' , '+ row.status +');">'+value+'</a>';
								}},
								{field:'price',title:'价格',width:60,align:'center',formatter: function(value,row,index){
									return '<span style="color:red;font-weight: bold;">'+row.price+'</span><br/><small style="opacity: 0.8;color: blue;margin-left: 5px;">(运费:'+row.freight+')</small>';
								}},
								{field:'payment',title:'支付方式',width:60,align:'center',formatter: function(value,row,index){
									return value == 1 ? "COD" : "STRIPE";
								}},
								{field:'statusName',title:'状态',width:60,align:'center'},
								{field:'currency',title:'结算币种',width:60,align:'center'},
								{field:'skus',title:'订单商品',width:200,align:'center', formatter: function(value,row,index){
									
									var _html = '<ul class="skuDetails">' ; 
									$.each(row.productSearchDTOs, function(index , productSearchDTO) {
										_html +='	<li>'+
												'		<img class="img" src="'+ productSearchDTO.productImageUrl +'" />'+
												'		<span class="productId">'+ productSearchDTO.productId +'(x'+ productSearchDTO.quantity +')</span>'+
												'		<span class="title">'+ productSearchDTO.productTitle +'</span>'+
												'		<span class="skuName">'+ productSearchDTO.productSkuName +'</span>'+
												'	</li>'
									});
									_html += '</ul>';
									return _html ; 
								}},
								{field:'consignee',title:'收件人',width:100,align:'center',formatter: function(value,row,index){
									return '<span>'+value+'</span><br/><span>(' + row.tel + ')</span>';
								}},
								{field:'address',title:'配送地址',width:180,align:'center'},
								{field:'deliveryCode',title:'发货单号',width:140,align:'center'},
								{field:'storehouseName',title:'发货仓库',width:80,align:'center'},
								{field:'createdAt',title:'下单时间',width:140,align:'center',formatter: function(value,row,index){
									return FormatDate(value);
								}},
								{field:'remark',title:'用户留言',width:150,align:'center'},
								{field:'options',title:'操作',width:180,align:'center', formatter: function(value,row,index){
									return '<div class="row-edit-group">' +
										        ((row.status == 10 || row.status == -30) ? '<a onclick="admin_order.orderAction.editOrder(\''+row.code+'\')">编辑</a>' : '') + 
										        ((row.status == 10 || row.status == -30) ? '<a onclick="admin_order.orderAction.cancelOrder(\''+row.code+'\')">取消</a>' : '') +
										        ((row.status == -30) ? '<a onclick="admin_order.orderAction.unholdOrder(\''+row.code+'\')">恢复</a>' : '') +
										        ((row.status == 10) ? '<a onclick="admin_order.orderAction.holdOrder(\''+row.code+'\')">挂起</a>' : '') +
										        ((row.status == 10 || row.status == -30 || row.status == -10) ? '<a onclick="admin_order.orderAction.deleteOrder(\''+row.code+'\')">删除</a>' : '') +
										   '</div>';
								}}
						    ]]
						});
					},
					merge: function(){
						var _checkeds = $('#adminOrder-datagrid').datagrid('getChecked');
						if(_checkeds.length <= 1){
							showMessage('2个以上的订单才可以合并...');
							return;
						}
						var param = []
						_checkeds.map((e)=>{
							param.push(e.code)
						})
						requestBodyServer(commonConfig.mgUrlPrefix() + '/admin/order/merge' , 'PUT', param).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
								$('#adminOrderEditWin').window('open');
								$('#adminOrderEditForm').form('clear');
								if(response.datas){
									$('#adminOrderEditForm').form('load' , response.datas);
								}
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					others: function(){
						var _formData = $('#otherOrderForm').serializeJson() ;
						requestBodyServer(commonConfig.mgUrlPrefix() + '/admin/order/others' , 'PUT', _formData).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
								$('#otherOrderWin').window('close');
								admin_order.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					showSKU: function(orderCode , orderStatus){
						admin_order.datas.orderCode = orderCode ;
						admin_order.datas.orderStatus = orderStatus ;
						$('#adminOrder-skuDetais-window').window('open');
						$('#adminOrder-skuDetais-datagrid').datagrid({
							url: commonConfig.mgUrlPrefix() + '/admin/order/'+orderCode+'/products',
							pagination:false,
						    columns:[[
						    	{field:'ck',checkbox:true},
						    	{field:'productId',title:'产品ID',width:80,align:'center',formatter:function(value,row,index){return '<span>'+row.productId+'</span><br/><span style="opacity: 0.8;">('+row.productSkuBarcode+')</span>';}},
						    	{field:'productTitle',title:'产品名称',width:120,align:'center',formatter:function(value,row,index){return '<span>'+row.productTitle+'</span><br/><span style="opacity: 0.8;">('+row.productSkuName+')</span>';}},
						    	{field:'productImageUrl',title:'产品图片',width:60,align:'center',formatter:function(value,row,index){return '<img class="td-img" src="'+ value +'">';}},
								{field:'productPrice',title:'价格',width:60,align:'center'},
								{field:'quantity',title:'待发/库存/占用',width:80,align:'center',formatter:function(value,row,index){ return row.quantity + '/' + row.inventoryQuantity + '/' + row.pendingDeliveryQuantity; }},
								{field:'supplierName',title:'供应商',width:80,align:'center',formatter:function(value,row,index){return (row.sourceNumber) ? '<span>'+row.supplierName+'</span><br/><span style="opacity: 0.8;">('+row.sourceNumber+')</span>' : '<span>'+row.supplierName+'</span>';}},
								{field:'sourceUrl',title:'采购链接',width:150,align:'center'},
								{field:'referencePurchasePrice',title:'采购价',width:50,align:'center'},
								{field:'options',title:'操作',width:80,align:'center', formatter: function(value,row,index){
									if(orderStatus == 10 || orderStatus == -30){
										return '<div class="row-edit-group">' +
											        '<a onclick="admin_order.orderAction.editOrderSku('+ index +')">编辑</a>' + 
											        '<a onclick="admin_order.orderAction.cancelOrderSku('+ index +')">删除</a>' +
											   '</div>';
									}
									return '' ; 
								}}
						    ]]
						});
						
					},
					splitOrder: function(){
						if(admin_order.datas.orderStatus != 10 && admin_order.datas.orderStatus != -30){
							showMessage('状态不允许操作');
							return ;
						}
						var _checkeds = $('#adminOrder-skuDetais-datagrid').datagrid('getChecked');
						var _rows = $('#adminOrder-skuDetais-datagrid').datagrid('getData').rows ; 
						if(_checkeds.length >= _rows.length){
							showMessage('拆单商品数量不能超过订单商品数量');
							return ;
						}
						var _orderProductId = [] ; 
						$.each(_checkeds, function(index, _checked) {
							_orderProductId.push(_checked.orderProductId);
						});
						requestBodyServer(commonConfig.mgUrlPrefix() + '/admin/order/'+ admin_order.datas.orderCode + '/split' , 'PUT', _orderProductId).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
								$('#adminOrder-skuDetais-window').window('close');
								admin_order.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					queryDatagrid: function(){
						$('#adminOrder-datagrid').datagrid('reload',admin_order.methods.initDatagridQueryParams());
					},
					uploadOrders: function(e){
						var _file = e.files[0];
						var type = _file.name.split('.');
						if (type[type.length - 1] !== 'xlsx' && type[type.length - 1] !== 'xls') {
					      	showMessage('<i class="fa fa-info-circle"></i>&nbsp; 只能选择excel文件...');
					      	return false;
					    }
						const reader = new FileReader();
					    reader.readAsBinaryString(_file);
					    reader.onload = (e) => {
					      	const data = e.target.result;
					      	const zzexcel = window.XLS.read(data, {type: 'binary'});
					      	const paramList = window.XLS.utils.sheet_to_json(zzexcel.Sheets[zzexcel.SheetNames[0]]);
					      	var list = [] // 处理后的数据
							var index = -1 // 当前收货单单下标
							for (let i = 1; i < paramList.length; i++) {
								debugger;
								if (paramList[i]['订单编号']) {
									// push收货单
									list.push({
										'code': paramList[i]['订单编号'],
										'payment': (paramList[i]['支付方式'] == 'COD' ? 1 : 2),
										'comments': paramList[i]['上传订单'],
										'price': paramList[i]['订单总价'],
										'freight': paramList[i]['运费'],
										'currency': paramList[i]['币种'],
										'contry': paramList[i]['国家'],
										'province': paramList[i]['省份'],
										'city': paramList[i]['城市'],
										'district': paramList[i]['区域'],
										'details': paramList[i]['详情'],
										'consignee': paramList[i]['收件人'],
										'tel': paramList[i]['电话'],

										'orderToAdminProductRequests': [{
											'productId': paramList[i]['订单明细'],
											'productTitle': paramList[i]['__EMPTY'],
											'productSkuId': paramList[i]['__EMPTY_1'],
											'productSkuBarcode': paramList[i]['__EMPTY_2'],
											'productSkuName': paramList[i]['__EMPTY_3'],
											'productPrice': paramList[i]['__EMPTY_4'],
											'productImageUrl': paramList[i]['__EMPTY_5'],
											'quantity': paramList[i]['__EMPTY_6']
										}]
									})
									index++
								} else {
									if (paramList[i]['__EMPTY_1']) {
										list[index]['orderToAdminProductRequests'].push({
											'productId': paramList[i]['订单明细'],
											'productTitle': paramList[i]['__EMPTY'],
											'productSkuId': paramList[i]['__EMPTY_1'],
											'productSkuBarcode': paramList[i]['__EMPTY_2'],
											'productSkuName': paramList[i]['__EMPTY_3'],
											'productPrice': paramList[i]['__EMPTY_4'],
											'productImageUrl': paramList[i]['__EMPTY_5'],
											'quantity': paramList[i]['__EMPTY_6']
										})
									}
								}
							}
							if(list.length == 0){
								$.messager.alert('提示','上传内容为空','error');
								return ;
							}
							requestBodyServer(commonConfig.mgUrlPrefix() + '/admin/order/uploads' , 'PUT', list).then((response) => {
								if (response.code == 1) {
									showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
									admin_order.methods.queryDatagrid();
								}else {
									$.messager.alert('提示',response.message,'error');
								}
							}).catch((error) => {
								console.log(error)
							});
					    }
					}
				},
				orderAction: {
					editOrder: function(orderCode){
						console.log(orderCode)
						$('#adminOrderEditWin').window('open');
						$('#adminOrderEditForm').form('clear');
						var rows = $('#adminOrder-datagrid').datagrid('getRows') ; 
						var editRow = null ;
						$.each(rows, function(index , _row) {
							if(_row.code == orderCode){
								editRow = _row ; 
								return false;
							}
						});
						if(editRow){
							var _address = editRow.address.split(' ');
							editRow.city = _address[0]; editRow.district = _address[1]; editRow.details = _address[2];
							$('#adminOrderEditForm').form('load' , editRow);
						}
					},
					editOrderSubimt: function(){
						var _formData = $('#adminOrderEditForm').serializeJson() ;
						requestBodyServer(commonConfig.mgUrlPrefix() + '/admin/order/'+ _formData.code , 'PUT', _formData).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
								$('#adminOrderEditWin').window('close');
								admin_order.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					unholdOrder: function(orderCode){
						requestServer(commonConfig.mgUrlPrefix() + '/admin/order/' + orderCode + '/unHold', 'PUT').then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 操作成功...');
								admin_order.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					cancelOrder: function(orderCode){
						$.messager.confirm('提示', '确定取消?', function(r){
							if (r){
								requestServer(commonConfig.mgUrlPrefix() + '/admin/order/' + orderCode + '/cancel', 'PUT').then((response) => {
									if (response.code == 1) {
										showMessage('<i class="fa fa-info-circle"></i>&nbsp; 操作成功...');
										admin_order.methods.queryDatagrid();
									}else {
										$.messager.alert('提示',response.message,'error');
									}
								}).catch((error) => {
									console.log(error)
								});
							}
						});
					},
					cancels: function(){
						var _checkeds = $('#adminOrder-datagrid').datagrid('getChecked');
						if(_checkeds.length <= 0){
							showMessage('没有选择订单');
							return;
						}
						var param = []
						_checkeds.map((e)=>{
							param.push(e.code)
						});
						requestBodyServer(commonConfig.mgUrlPrefix() + '/admin/order/cancels', 'PUT', param).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 操作成功...');
								admin_order.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					deletes: function(){
						var _checkeds = $('#adminOrder-datagrid').datagrid('getChecked');
						if(_checkeds.length <= 0){
							showMessage('没有选择订单');
							return;
						}
						var param = []
						_checkeds.map((e)=>{
							param.push(e.code)
						});
						requestBodyServer(commonConfig.mgUrlPrefix() + '/admin/order/deletes', 'PUT', param).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 操作成功...');
								admin_order.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					holdOrder: function(orderCode){
						requestServer(commonConfig.mgUrlPrefix() + '/admin/order/' + orderCode + '/hold', 'PUT').then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 操作成功...');
								admin_order.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					},
					deleteOrder: function(orderCode){
						$.messager.confirm('提示', '确定删除?', function(r){
							if (r){
								requestServer(commonConfig.mgUrlPrefix() + '/admin/order/' + orderCode, 'DELETE').then((response) => {
									if (response.code == 1) {
										showMessage('<i class="fa fa-info-circle"></i>&nbsp; 删除成功...');
										admin_order.methods.queryDatagrid();
									}else {
										$.messager.alert('提示',response.message,'error');
									}
								}).catch((error) => {
									console.log(error)
								});
							}
						});
					},
					editOrderSku: function(index){
						$('#adminOrderSkuEditWin').window('open');
						$('#adminOrderSkuEditForm').form('clear');
						$('#adminOrderSkuEditForm').form('load' , $('#adminOrder-skuDetais-datagrid').datagrid('getRows')[index]);
					},
					cancelOrderSku: function(index){
						$.messager.confirm('提示', '确定删除?', function(r){
							if (r){
								requestServer(commonConfig.mgUrlPrefix() + '/admin/order/product/' + $('#adminOrder-skuDetais-datagrid').datagrid('getRows')[index].orderProductId, 'DELETE').then((response) => {
									if (response.code == 1) {
										showMessage('<i class="fa fa-info-circle"></i>&nbsp; 删除成功...');
										$('#adminOrder-skuDetais-datagrid').datagrid('reload');
									}else {
										$.messager.alert('提示',response.message,'error');
									}
								}).catch((error) => {
									console.log(error)
								});
							}
						});
					},
					editOrderSkuSubimt: function(){
						var _formData = $('#adminOrderSkuEditForm').serializeJson() ;
						requestBodyServer(commonConfig.mgUrlPrefix() + '/admin/order/product/'+ _formData.orderProductId , 'PUT', _formData).then((response) => {
							if (response.code == 1) {
								showMessage('<i class="fa fa-info-circle"></i>&nbsp; 请求成功...');
								$('#adminOrderSkuEditWin').window('close');
								$('#adminOrder-skuDetais-datagrid').datagrid('reload');
								admin_order.methods.queryDatagrid();
							}else {
								$.messager.alert('提示',response.message,'error');
							}
						}).catch((error) => {
							console.log(error)
						});
					}
				},
				init : function(){
					admin_order.methods.initTimeSelect();
					admin_order.methods.initDatagrid();
				}
			}
			admin_order.init();
		</script>
	</body>
</html>
